<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			function fun(){
				let t1=document.getElementById("t1").value
				if(t1==""){
					document.getElementById("s1").innerHTML="姓名不能为空"
					return false
				} else{
					document.getElementById("s1").innerHTML="通过验证"
				}
				let t2=document.getElementById("t2").value
				if(t2.length<6){
					document.getElementById("s2").innerHTML="密码长度不足6位"
					return false
				}else{
					document.getElementById("s2").innerHTML="通过验证"
				}
				
				
				let t3=document.getElementById("t3").value
				if(isNaN(t3) || t3 <= 0 || t3 >= 150){
					document.getElementById("s3").innerHTML="年龄必须是0-150之间";
					return false;
				}else{
					document.getElementById("s3").innerHTML="通过验证";
				}
				
				let t4=document.getElementById("t4").value;
				let reg = /^1\d{10}$/;
				if(!reg.test(t4)){
					document.getElementById("s4").innerHTML="手机号不合法";
					return false;
				}else{
					document.getElementById("s4").innerHTML="通过验证";
				}
				
				return false  //开发过程中应该在此处为true
			}
			
		</script>
		
	</head>
	<body>
		<form action="" onsubmit="return fun()">
			姓名：<input type="text" id="t1" />
			<span id="s1"></span><br>
			密码：<input type="password" id="t2" />
			<span id="s2"></span><br>
			年龄：<input type="text" id="t3" />
			<span id="s3"></span><br>
			手机：<input type="text" id="t4" />
			<span id="s4"></span><br>
			<input type="submit"/>
		</form>
	</body>
</html>
